package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperActivityType;
import com.ruoyi.system.service.ISuperActivityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 活动大类Controller
 * 
 * @author xjf
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/activity/type")
public class SuperActivityTypeController extends BaseController
{
    @Autowired
    private ISuperActivityTypeService superActivityTypeService;

    /**
     * 查询活动大类列表
     */
    @PreAuthorize("@ss.hasPermi('activity:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperActivityType superActivityType)
    {
        startPage();
        List<SuperActivityType> list = superActivityTypeService.selectSuperActivityTypeList(superActivityType);
        return getDataTable(list);
    }

    /**
     * 导出活动大类列表
     */
    @PreAuthorize("@ss.hasPermi('activity:type:export')")
    @Log(title = "活动大类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperActivityType superActivityType)
    {
        List<SuperActivityType> list = superActivityTypeService.selectSuperActivityTypeList(superActivityType);
        ExcelUtil<SuperActivityType> util = new ExcelUtil<SuperActivityType>(SuperActivityType.class);
        util.exportExcel(response, list, "活动大类数据");
    }

    /**
     * 获取活动大类详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superActivityTypeService.selectSuperActivityTypeById(id));
    }

    /**
     * 新增活动大类
     */
    @PreAuthorize("@ss.hasPermi('activity:type:add')")
    @Log(title = "活动大类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperActivityType superActivityType)
    {
        return toAjax(superActivityTypeService.insertSuperActivityType(superActivityType));
    }

    /**
     * 修改活动大类
     */
    @PreAuthorize("@ss.hasPermi('activity:type:edit')")
    @Log(title = "活动大类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperActivityType superActivityType)
    {
        return toAjax(superActivityTypeService.updateSuperActivityType(superActivityType));
    }

    /**
     * 删除活动大类
     */
    @PreAuthorize("@ss.hasPermi('activity:type:remove')")
    @Log(title = "活动大类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superActivityTypeService.deleteSuperActivityTypeByIds(ids));
    }
}
